using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;

using Plain;
using Plain.Data;
using Plain.Search;
using Plain.Web.Mvc.Controllers;

using Plain.Demo.Blog.Business;
using Plain.Demo.Blog.Web;

namespace Plain.Demo.Blog.Web.UI
{
	[HandleError]
	public class CommentController : PlainController<Comment>
	{
		public ActionResult Edit(int id){
			var result = 
				p * p["Post"]
				/ 
				(p["Title"]=="bla");
			
			var comments = p * id;
			
			foreach(var r in result){}
			
			ISearchableDao<Comment, int> dao = PlainApplication.Config.DaoFactory.GetDao<Comment, int> ();
			var comment = dao.Get (id);
			return View(comment);
		}
		
		[ValidateInput(false)]
		[AcceptVerbs(HttpVerbs.Post)]
		public ActionResult Edit(int id, Comment comment){
			try {
				comment.Save ();
				return RedirectToAction ("Index","Post");
			} catch {
				return View ();
			}
		}
		
		
		public ActionResult Delete(Comment comment){
			comment.Delete();
			return RedirectToAction ("Index","Post");
		}
	}
}